package top.appx.service.impl;

import org.springframework.stereotype.Service;
import top.appx.dao.UserGroupDao;
import top.appx.entity.UserGroupEntity;
import top.appx.service.UserGroupService;
import top.appx.vo.Pager;
import top.appx.vo.UserGroupVO;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by zwy on 2015-5-21.
 */
@Service
public class UserGroupServiceImpl implements UserGroupService {

    @Resource
    private UserGroupDao userGroupDao;
    public Pager<UserGroupVO> queryByPage(UserGroupEntity bean, int page, int rows) {
        Pager<UserGroupEntity> pager = userGroupDao.queryByPage(bean,page,rows);
        Pager<UserGroupVO> pagerVO = new Pager<UserGroupVO>();
        List<UserGroupVO> list = new ArrayList<UserGroupVO>();
        for (UserGroupEntity ug:pager.getRows()){
            UserGroupVO ugv = new UserGroupVO(ug);
            list.add(ugv);
        }
        pagerVO.setRows(list);
        pagerVO.setTotal(pager.getTotal());
        return pagerVO;
    }

    public void save(UserGroupEntity entity) {
        userGroupDao.save(entity);
    }
    public void delete(UserGroupEntity entity) {
        userGroupDao.delete(entity);
    }

    public UserGroupVO queryById(int id) {
        return null;
    }
}
